<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- 
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License. 
-->
<html>
<head>
    <link type="text/css" rel="stylesheet" href="https://struts.apache.org/css/default.css">
    <style type="text/css">
        .dp-highlighter {
            width:95% !important;
        }
    </style>
    <style type="text/css">
        .footer {
            background-image:      url('https://cwiki.apache.org/confluence/images/border/border_bottom.gif');
            background-repeat:     repeat-x;
            background-position:   left top;
            padding-top:           4px;
            color:                 #666;
        }
    </style>
    <link href='https://struts.apache.org/highlighter/style/shCoreStruts.css' rel='stylesheet' type='text/css' />
    <link href='https://struts.apache.org/highlighter/style/shThemeStruts.css' rel='stylesheet' type='text/css' />
    <script src='https://struts.apache.org/highlighter/js/shCore.js' type='text/javascript'></script>
    <script src='https://struts.apache.org/highlighter/js/shBrushPlain.js' type='text/javascript'></script>
    <script src='https://struts.apache.org/highlighter/js/shBrushXml.js' type='text/javascript'></script>
    <script src='https://struts.apache.org/highlighter/js/shBrushJava.js' type='text/javascript'></script>
    <script src='https://struts.apache.org/highlighter/js/shBrushJScript.js' type='text/javascript'></script>
    <script src='https://struts.apache.org/highlighter/js/shBrushGroovy.js' type='text/javascript'></script>
    <script src='https://struts.apache.org/highlighter/js/shBrushBash.js' type='text/javascript'></script>
    <script type="text/javascript">
        SyntaxHighlighter.defaults['toolbar'] = false;
        SyntaxHighlighter.all();
    </script>
    <script type="text/javascript" language="javascript">
        var hide = null;
        var show = null;
        var children = null;

        function init() {
            /* Search form initialization */
            var form = document.forms['search'];
            if (form != null) {
                form.elements['domains'].value = location.hostname;
                form.elements['sitesearch'].value = location.hostname;
            }

            /* Children initialization */
            hide = document.getElementById('hide');
            show = document.getElementById('show');
            children = document.all != null ?
                    document.all['children'] :
                    document.getElementById('children');
            if (children != null) {
                children.style.display = 'none';
                show.style.display = 'inline';
                hide.style.display = 'none';
            }
        }

        function showChildren() {
            children.style.display = 'block';
            show.style.display = 'none';
            hide.style.display = 'inline';
        }

        function hideChildren() {
            children.style.display = 'none';
            show.style.display = 'inline';
            hide.style.display = 'none';
        }
    </script>
    <title>FreeMarker</title>
</head>
<body onload="init()">
<table border="0" cellpadding="2" cellspacing="0" width="100%">
    <tr class="topBar">
        <td align="left" valign="middle" class="topBarDiv" align="left" nowrap>
            &nbsp;<a href="home.html">Home</a>&nbsp;&gt;&nbsp;<a href="guides.html">Guides</a>&nbsp;&gt;&nbsp;<a href="tag-developers-guide.html">Tag Developers Guide</a>&nbsp;&gt;&nbsp;<a href="freemarker.html">FreeMarker</a>
        </td>
        <td align="right" valign="middle" nowrap>
            <form name="search" action="https://www.google.com/search" method="get">
                <input type="hidden" name="ie" value="UTF-8" />
                <input type="hidden" name="oe" value="UTF-8" />
                <input type="hidden" name="domains" value="" />
                <input type="hidden" name="sitesearch" value="" />
                <input type="text" name="q" maxlength="255" value="" />
                <input type="submit" name="btnG" value="Google Search" />
            </form>
        </td>
    </tr>
</table>

<div id="PageContent">
    <div class="pageheader" style="padding: 6px 0px 0px 0px;">
        <!-- We'll enable this once we figure out how to access (and save) the logo resource -->
        <!--img src="/wiki/images/confluence_logo.gif" style="float: left; margin: 4px 4px 4px 10px;" border="0"-->
        <div style="margin: 0px 10px 0px 10px" class="smalltext">Apache Struts 2 Documentation</div>
        <div style="margin: 0px 10px 8px 10px"  class="pagetitle">FreeMarker</div>

        <div class="greynavbar" align="right" style="padding: 2px 10px; margin: 0px;">
            <a href="https://cwiki.apache.org/confluence/pages/editpage.action?pageId=14078">
                <img src="https://cwiki.apache.org/confluence/images/icons/notep_16.gif"
                     height="16" width="16" border="0" align="absmiddle" title="Edit Page"></a>
            <a href="https://cwiki.apache.org/confluence/pages/editpage.action?pageId=14078">Edit Page</a>
            &nbsp;
            <a href="https://cwiki.apache.org/confluence/pages/listpages.action?key=WW">
                <img src="https://cwiki.apache.org/confluence/images/icons/browse_space.gif"
                     height="16" width="16" border="0" align="absmiddle" title="Browse Space"></a>
            <a href="https://cwiki.apache.org/confluence/pages/listpages.action?key=WW">Browse Space</a>
            &nbsp;
            <a href="https://cwiki.apache.org/confluence/pages/createpage.action?spaceKey=WW&fromPageId=14078">
                <img src="https://cwiki.apache.org/confluence/images/icons/add_page_16.gif"
                     height="16" width="16" border="0" align="absmiddle" title="Add Page"></a>
            <a href="https://cwiki.apache.org/confluence/pages/createpage.action?spaceKey=WW&fromPageId=14078">Add Page</a>
            &nbsp;
            <a href="https://cwiki.apache.org/confluence/pages/createblogpost.action?spaceKey=WW&fromPageId=14078">
                <img src="https://cwiki.apache.org/confluence/images/icons/add_blogentry_16.gif"
                     height="16" width="16" border="0" align="absmiddle" title="Add News"></a>
            <a href="https://cwiki.apache.org/confluence/pages/createblogpost.action?spaceKey=WW&fromPageId=14078">Add News</a>
        </div>
    </div>

    <div class="pagecontent">
        <div class="wiki-content">
            <div id="ConfluenceContent"><p><style type="text/css">/*<![CDATA[*/
div.rbtoc1440488800473 {padding: 0px;}
div.rbtoc1440488800473 ul {list-style: disc;margin-left: 0px;}
div.rbtoc1440488800473 li {margin-left: 0px;padding-left: 0px;}

/*]]>*/</style></p><div class="toc-macro rbtoc1440488800473">
<ul class="toc-indentation"><li><a shape="rect" href="#FreeMarker-GettingStarted">Getting Started</a></li><li><a shape="rect" href="#FreeMarker-Servlet/JSPScopedObjects">Servlet / JSP Scoped Objects</a>
<ul class="toc-indentation"><li><a shape="rect" href="#FreeMarker-ApplicationScopeAttribute">Application Scope Attribute</a></li><li><a shape="rect" href="#FreeMarker-SessionScopeAttribute">Session Scope Attribute</a></li><li><a shape="rect" href="#FreeMarker-RequestScopeAttribute">Request Scope Attribute</a></li><li><a shape="rect" href="#FreeMarker-RequestParameter">Request Parameter</a></li><li><a shape="rect" href="#FreeMarker-Contextparameter">Context parameter</a></li></ul>
</li><li><a shape="rect" href="#FreeMarker-TemplateLoading">Template Loading</a></li><li><a shape="rect" href="#FreeMarker-VariableResolution">Variable Resolution</a></li><li><a shape="rect" href="#FreeMarker-TagSupport">Tag Support</a></li><li><a shape="rect" href="#FreeMarker-TipsandTricks">Tips and Tricks</a>
<ul class="toc-indentation"><li><a shape="rect" href="#FreeMarker-TypeConversionandLocales">Type Conversion and Locales</a></li><li><a shape="rect" href="#FreeMarker-Extending">Extending</a></li><li><a shape="rect" href="#FreeMarker-ObjectWrapperSettings">ObjectWrapper Settings</a></li><li><a shape="rect" href="#FreeMarker-SyntaxNotes">Syntax Notes</a></li><li><a shape="rect" href="#FreeMarker-Cache">Cache</a></li><li><a shape="rect" href="#FreeMarker-IncompatibleImprovements">Incompatible Improvements</a></li></ul>
</li><li><a shape="rect" href="#FreeMarker-Next:">Next: FreeMarker Tags</a></li></ul>
</div><p>FreeMarker is a Java-based template engine that is a great alternative to <a shape="rect" href="jsp.html">JSP</a>. FreeMarker is ideal for situations where your action results can possibly be loaded from outside a Servlet container. For example, if you wished to support plugins in your application, you might wish to use FreeMarker so that the plugins could provide the entire action class and view in a single jar that is loaded from the classloader.</p><p>For more information on FreeMarker itself, please visit the <a shape="rect" class="external-link" href="http://freemarker.sourceforge.net/" rel="nofollow">FreeMarker website</a>.</p><div class="confluence-information-macro confluence-information-macro-note"><span class="aui-icon aui-icon-small aui-iconfont-warning confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>The framework utilizes FreeMarker because the engine includes strong error reporting, built-in internationalization and powerful macro libraries.</p><p>Support is also included for <a shape="rect" href="velocity.html">Velocity</a> templates. For a comparison of Velocity vs FreeMarker see <a shape="rect" class="external-link" href="http://freemarker.org/fmVsVel.html" rel="nofollow">here</a>.</p></div></div><h2 id="FreeMarker-GettingStarted">Getting Started</h2><p>Getting started with FreeMarker is as simple as ensuring all the dependencies are included in your project's classpath. Typically, the only dependency is <code>freemarker.jar</code>. Other than that, <a shape="rect" href="struts-defaultxml.html">struts-default.xml</a> already configures the <a shape="rect" href="freemarker-result.html">FreeMarker Result</a> needed to process your application's templates.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>struts.xml</b></div><div class="codeContent panelContent pdl">
<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;">&lt;action name="test" class="com.acme.TestAction"&gt;
    &lt;result name="success" type="freemarker"&gt;test-success.ftl&lt;/result&gt;
&lt;/action&gt;
</pre>
</div></div><p>Then in <code>test-success.ftl</code>:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>test-success.ftl</b></div><div class="codeContent panelContent pdl">
<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;">&lt;html&gt;
&lt;head&gt;
    &lt;title&gt;Hello&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;

Hello, ${name}

&lt;/body&gt;
&lt;/html&gt;
</pre>
</div></div><p>Where <code>name</code> is a property on your action. That's it! Read the rest of this document for details on how templates are loaded, variables are resolved, and tags can be used.</p><h2 id="FreeMarker-Servlet/JSPScopedObjects">Servlet / JSP Scoped Objects</h2><p>The following are ways to obtained Application scope attributes, Session scope attributes, Request scope attributes, Request parameters, and framework Context scope parameters:-</p><h3 id="FreeMarker-ApplicationScopeAttribute">Application Scope Attribute</h3><p>Assuming there's an attribute with name <code>myApplicationAttribute</code> in the Application scope.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">&lt;#if Application.myApplicationAttribute?exists&gt;
     ${Application.myApplicationAttribute}
&lt;/#if&gt;
</pre>
</div></div><p>or</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">&lt;@s.property value="%{#application.myApplicationAttribute}" /&gt;
</pre>
</div></div><h3 id="FreeMarker-SessionScopeAttribute">Session Scope Attribute</h3><p>Assuming there's an attribute with name <code>mySessionAttribute</code> in the Session scope.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">&lt;#if Session.mySessionAttribute?exists&gt;
     ${Session.mySessionAttribute}
&lt;/#if&gt;
</pre>
</div></div><p>or</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">&lt;@s.property value="%{#session.mySessionAttribute}" /&gt;
</pre>
</div></div><h3 id="FreeMarker-RequestScopeAttribute">Request Scope Attribute</h3><p>Assuming there's an attribute with name 'myRequestAttribute' in the Request scope.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">&lt;#if Request.myRequestAttribute?exists&gt;
      ${Request.myRequestAttribute}
&lt;/#if&gt;
</pre>
</div></div><p>or</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">&lt;@s.property value="%{#request.myRequestAttribute}" /&gt;
</pre>
</div></div><h3 id="FreeMarker-RequestParameter">Request Parameter</h3><p>Assuming there's a request parameter myParameter (eg. <a shape="rect" class="external-link" href="http://host/myApp/myAction.action?myParameter=one" rel="nofollow">http://host/myApp/myAction.action?myParameter=one</a>).</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">&lt;#if Parameters.myParameter?exists&gt;
     ${Parameters.myParameter}
&lt;/#if&gt;
</pre>
</div></div><p>or</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">&lt;@s.property value="%{#parameters.myParameter}" /&gt;
</pre>
</div></div><h3 id="FreeMarker-Contextparameter">Context parameter</h3><p>Assuming there's a parameter with the name myContextParam in framework context.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">${stack.findValue('#myContextParam')}
</pre>
</div></div><p>or</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">&lt;@s.property value="%{#myContextParam}" /&gt;
</pre>
</div></div><h2 id="FreeMarker-TemplateLoading">Template Loading</h2><p>The framework looks for FreeMarker templates in two locations (in this order):</p><ol><li>Web application</li><li>Class path</li></ol><p>This ordering makes it ideal for providing templates inside a fully-built jar, but allowing for overrides of those templates to be defined in your web application. In fact, this is how you can override the default UI tags and <a shape="rect" href="form-tags.html">Form Tags</a> included with the framework.</p><p>In addition, you can specify a location (directory on your file system) through the <code>templatePath</code> or <code>TemplatePath</code> context variable (in the <code>web.xml</code>). If a variable is specified, the content of the directory it points to will be searched first.</p><div class="confluence-information-macro confluence-information-macro-note"><span class="aui-icon aui-icon-small aui-iconfont-warning confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>This variable is currently NOT relative to the root of your application.</p></div></div><h2 id="FreeMarker-VariableResolution">Variable Resolution</h2><p>When using FreeMarker with the framework, variables are looked up in several different places, in this order:</p><ol><li>Built-in variables</li><li>Value stack</li><li>Action context</li><li>Request scope</li><li>Session scope</li><li>Application scope</li></ol><p>Note that the action context is looked up after the value stack. This means that you can reference the variable without the typical preceding has marker (#) like you would have to when using the JSP <code>s:property</code> tag. This is a nice convenience, though be careful because there is a small chance it could trip you up.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;">&lt;@s.url id="url" value="http://www.yahoo.com"/&gt;
Click &lt;a xhref="${url}"&gt;here&lt;/a&gt;!
</pre>
</div></div><p>The built-in variables that Struts-FreeMarker integration provides are:</p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Name</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>stack</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The value stack itself, useful for calls like ${stack.findString('ognl expr')}</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>action</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The action most recently executed</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>response</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The HttpServletResponse</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>res</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Same as response</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>request</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The HttpServletRequest</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>req</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Same as request</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>session</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The HttpSession</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>application</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The ServletContext</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>base</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The request's context path</p></td></tr></tbody></table></div><h2 id="FreeMarker-TagSupport">Tag Support</h2><p>FreeMarker includes complete tag support. See the <a shape="rect" href="freemarker-tags.html">FreeMarker Tags</a> documentation for information on how to use the generic <a shape="rect" href="struts-tags.html">Struts Tags</a> provided by Struts. In addition to this, you can use any JSP tag, like so:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;">&lt;#assign mytag=JspTaglibs["/WEB-INF/mytag.tld"]&gt;
&lt;@mytag.tagx attribute1="some ${value}"/&gt;
</pre>
</div></div><p>Where <strong>mytag.tld</strong> is the JSP Tag Library Definition file for your tag library. Note: in order to use this support in FreeMarker, you must enable the <code>JSPSupportServlet</code> in <code>web.xml</code>:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Adding JspSupportSerlvet to web.xml</b></div><div class="codeContent panelContent pdl">
<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;">&lt;servlet&gt;
    &lt;servlet-name&gt;JspSupportServlet&lt;/servlet-name&gt;
    &lt;servlet-class&gt;org.apache.struts2.views.JspSupportServlet&lt;/servlet-class&gt;
    &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
&lt;/servlet&gt;
</pre>
</div></div><h2 id="FreeMarker-TipsandTricks">Tips and Tricks</h2><p>There are some advanced features that may be useful when building Struts applications with FreeMarker.</p><h3 id="FreeMarker-TypeConversionandLocales">Type Conversion and Locales</h3><p>FreeMarker has built in support for formatting dates and numbers. The formatting rules are based on the locale associated with the action request, which is by default set in <a shape="rect" href="strutsproperties.html">struts.properties</a> but can be over-ridden using the <a shape="rect" href="i18n-interceptor.html">I18n Interceptor</a>. This is normally perfect for your needs, but it is important to remember that these formatting rules are handled by FreeMarker and not by the framework's <a shape="rect" href="type-conversion.html">Type Conversion</a> support.</p><p>If you want the framework to handle the formatting according to the <a shape="rect" href="type-conversion.html">Type Conversion</a> you have specified, you shouldn't use the normal ${...} syntax. Instead, you should use the <a shape="rect" href="property.html">property</a> tag. The difference is that the property tag is specifically designed to take an <a shape="rect" href="ognl.html">OGNL</a> expression, evaluate it, and then convert it to a String using any <a shape="rect" href="type-conversion.html">Type Conversion</a> rules you have specified. The normal ${...} syntax will use a FreeMarker expression language, evaluate it, and then convert it to a String using the built in formatting rules.</p><p><img class="emoticon emoticon-warning" src="https://cwiki.apache.org/confluence/s/en_GB/5982/f2b47fb3d636c8bc9fd0b11c0ec6d0ae18646be7.1/_/images/icons/emoticons/warning.png" data-emoticon-name="warning" alt="(warning)"> The difference in how type conversion is handled under Freemarker is subtle but important to understand.</p><h3 id="FreeMarker-Extending">Extending</h3><p>Sometimes you may with to extend the framework's FreeMarker support. For example, you might want to extend the Struts tags that come bundled with the framework.</p><p>To extend the Freemarker support, develop a class that extends <code>org.apache.struts2.views.freemarker.FreemarkerManager</code>, overriding methods as needed, and plugin the class through the <a shape="rect" href="strutsproperties.html">struts.properties</a>:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="brush: plain; gutter: false; theme: Default" style="font-size:12px;">struts.freemarker.manager.classname = com.yourcompany.YourFreeMarkerManager
</pre>
</div></div><h3 id="FreeMarker-ObjectWrapperSettings">ObjectWrapper Settings</h3><p>Once you get familiar with FreeMarker, you will find certain <em>subtleties</em>with it that may become frustrating. The most common thing you'll likely run in to is the BeansWrapper provided by FreeMarker. If you don't know what this is, don't worry. However, if you do, know this:</p><p></p><p>
The StrutsBeanWrapper extends the default FreeMarker BeansWrapper and provides almost no change in functionality,
<b>except</b> for how it handles maps. Normally, FreeMarker has two modes of operation: either support for friendly
map built-ins (?keys, ?values, etc) but only support for String keys; OR no special built-in support (ie: ?keys
returns the methods on the map instead of the keys) but support for String and non-String keys alike. Struts
provides an alternative implementation that gives us the best of both worlds.
</p>

<p></p><p> It is possible that this special behavior may be confusing or can cause problems. Therefore, you can set the
<b>struts.freemarker.wrapper.altMap</b> property in struts.properties to false, allowing the normal BeansWrapper
logic to take place instead.
</p><h3 id="FreeMarker-SyntaxNotes">Syntax Notes</h3><p>As of FreeMarker 2.3.4, an alternative syntax is supported. This alternative syntax is great if you find that your IDE (especially IntelliJ IDEA) makes it difficult to work with the default syntax. You can read more about this syntax <a shape="rect" class="external-link" href="http://freemarker.sourceforge.net/docs/dgui_misc_alternativesyntax.html" rel="nofollow">here</a>.</p><h3 id="FreeMarker-Cache">Cache</h3><p>You can enable FreeMarker cache mechanism by specifying below options in struts.xml:</p><ul><li><code>&lt;constant name="struts.freemarker.mru.max.strong.size" value="250" /&gt;</code> - this option will be used by <a shape="rect" class="external-link" href="http://freemarker.org/docs/api/freemarker/cache/MruCacheStorage.html" rel="nofollow">freemarker.cache.MruCacheStorage</a></li></ul><ul><li><code>&lt;constant name="struts.freemarker.templatesCache.updateDelay" value="1800" /&gt;</code> - default update cache interval (5 seconds)</li></ul><ul><li><code>&lt;constant name="struts.freemarker.templatesCache" value="true" /&gt;</code> - *<strong>DEPRECATED</strong>* this option will use a internal ConcurrentHashMap in FreemarkerTemplateEngine but not freemarker native cache</li></ul><p>Setting <code>devMode</code> to true will disable cache and updateDelay immediately, but you can explicit specify these constants to enable cache even in <code>devMode</code>, see <a shape="rect" href="devmode.html">devMode</a></p><h3 id="FreeMarker-IncompatibleImprovements">Incompatible Improvements</h3><p>By default Struts is using FreeMarker in way to be backward compatible as much as possible&#160;but if you need to enable new features you can do it via&#160;<code>freemarker.properties</code> by defining <a shape="rect" class="external-link" href="http://freemarker.org/docs/pgui_config_incompatible_improvements.html#pgui_config_incompatible_improvements_how_to_set" rel="nofollow">incompatible improvements</a> settings, ie.:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>freemarker.properties</b></div><div class="codeContent panelContent pdl">
<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">incompatible_improvements=2.3.22</pre>
</div></div><p>This can impact your freemarker powered pages and Struts tags as well, so please careful test this change.</p><h2 id="FreeMarker-Next:">Next: <a shape="rect" href="freemarker-tags.html">FreeMarker Tags</a></h2></div>
        </div>

        
    </div>
</div>
<div class="footer">
    Generated by CXF SiteExporter
</div>
</body>
</html>
